$(function () {

    //轮播图
    $.get('/eshop/carouselFigure.do?m=findAll',function (res) {
        res.data.forEach(function (e,i) {
            $("#pic").append('<li><a href="javascript:void(0);"><img src="/eshop/Img.do?m=showImg&name='+e.url+'" alt="" width="1020px" height="360px"/></a></li>')
        })
    },'json')

    //排行版
    $.get('/eshop/orderProduct.do?m=rank',function (res) {
        res.forEach(function (e,i) {
            $(".rank-list>ul").append('<li><a href="javascript:void(0);" onclick="toGoodsDetail(\''+e.productId+'\')"><span class="rank-icon1">'+(i+1)+'</span><img src="/eshop/Img.do?m=showImg&name='+e.product.productImage+'" alt="" width="90px" height="90px"/> <p>'+e.product.productName+'</p> </a> </li>')
        })
    },'json')

    //新品
    $.get('/eshop/product.do?m=newProduct',function (res) {
        res.forEach(function (e,i) {
            $(".new-list>ul").append('  <li><a href="javascript:void(0);"  onclick="toGoodsDetail(\''+e.id+'\')"> <img src="/eshop/Img.do?m=showImg&name='+e.productImage+'" alt="" width="90px" height="90px"/><p>'+e.productName+'</p></a></li>')
        })
    },'json')

    //分类

    //全球进口
    $.get('/eshop/product.do?m=sortProduct',{productTypeName:$("#global-foot>.h-title").text(),limit:5},function (res) {
         res.forEach(function (e,i) {
             $(".global-list>ul").append('<li><a href="javascript:void(0);"  onclick="toGoodsDetail(\''+e.id+'\')"><p>'+e.productName+'</p><img src="/eshop/Img.do?m=showImg&name='+e.productImage+'" alt="" width="150px" height="150px"/></a></li>')
         })
    },'json')

    //服装服饰
    $.get('/eshop/product.do?m=sortProduct',{productTypeName:$("#cloth>.h-title").text(),limit:12},function (res) {
        res.forEach(function (e,i) {
            let str = '<li><a href="javascript:void(0);"  onclick="toGoodsDetail(\''+e.id+'\')">\n' +
                '<div class="c-img"><img src="/eshop/Img.do?m=showImg&name='+e.productImage+'" alt="" width="180px" height="180px"/></div>\n' +
                '<p class="c-title">'+e.productName+'</p>\n' +
                '<span class="c-price">￥'+e.price+'</span>\n' +
                '</a></li>'
            $(".cloth-list>ul").append(str)
        })
    },'json')

    //护肤美妆
    $.get('/eshop/product.do?m=sortProduct',{productTypeName:$("#cloth>.h-title").text(),limit:5},function (res) {
        console.log(res);
        res.forEach(function (e,i) {
            let str ='<li><a href="javascript:void(0);" onclick="toGoodsDetail(\''+e.id+'\')">\n' +
                '                <img src="/eshop/Img.do?m=showImg&name='+e.productImage+'"  alt="" width="100px" height="100px"/>\n' +
                '                <div class="mod-info">\n' +
                '                    <p class="m-title">'+e.productName+'</p>\n' +
                '                    <span class="m-price">￥'+e.price+'</span>\n' +
                '                </div>\n' +
                '            </a></li>'
            $(".mod-list>ul").append(str)
        })
    },'json')

    //图书学习
    $.get('/eshop/product.do?m=sortProduct',{productTypeName:$("#book>.h-title").text(),limit:12},function (res) {
        res.forEach(function (e,i) {
            $(".book-list>ul").append('<li><a href="javascript:void(0);"  onclick="toGoodsDetail(\''+e.id+'\')">\n' +
                '                <div class="c-img"><img src="/eshop/Img.do?m=showImg&name='+e.productImage+'" alt="" width="180px" height="180px"/></div>\n' +
                '                <p class="c-title">'+e.productName+'</p>\n' +
                '                <span class="c-price">'+e.price+'</span>\n' +
                '            </a></li>')
        })
    },'json')

})
